<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>${fns:getConfig('productName')}</title>
	<meta name="decorator" content="blank"/>
</head>
<body class="fixed-sidebar full-height-layout gray-bg" style="overflow:hidden">
<div id="wrapper" class="left-right-layout">
	<!--顶部导航开始-->
	<nav class="navbar navbar-static-top top-nav clearfix" role="navigation">
		<!-- 首页logo -->
		<div class="navbar-header ">
			<span class="nav-header logoTitle J_menuItem " style="display: inline-block;">
				<span class="logoImg"><img src="${ownStatic}/images/page-logo.svg" alt=""/></span>
				<span class="logoTitle J_menuItem">${fns:getConfig('productName')}</span>
			</span>
		</div>

		<!--横向总导航-->
		<ul class="transverse-total-navbar clearfix ">
			<c:set var="firstMenu" value="true"/>
			<c:forEach items="${fns:getMenuList()}" var="menu" varStatus="idxStatus">
				<c:if test="${menu.parent.id eq '1'&&menu.isShow eq '1'}">
					<li class="menu ${not empty firstMenu && firstMenu ? ' active' : ''}">
						<c:if test="${empty menu.href}">
							<a href="javascript:void(0);" data-href="${ctx}/sys/menu/tree?parentId=${menu.id}" data-id="${menu.id}">
								<span class="nav-label">${menu.name}</span>
							</a>
						</c:if>
						<c:if test="${not empty menu.href}">
							<a href="${fn:indexOf(menu.href, '://') eq -1 ? ctx : ''}${menu.href}" data-id="${menu.id}">
								<span class="nav-label">${menu.name}</span>
							</a>
						</c:if>
					</li>
					<c:if test="${firstMenu}">
						<c:set var="firstMenuId" value="${menu.id}"/>
					</c:if>
					<c:set var="firstMenu" value="false"/>
				</c:if>
			</c:forEach>
		</ul>

		<!-- 通知头像 -->
		<ul class="nav navbar-top-links navbar-right clearfix">
			<li class="dropdown pull-left">
				<a class="dropdown-toggle count-info J_menuItem" href="${ctx}/oa/oaNotify/self">
					<span style="display: none;">通知列表</span>
					<i class="fa icon-bell-alt"></i> <span class="label label-primary" id="notifyNum"></span>
				</a>
			</li>
			<li class="dropdown profile-element pull-left" style="height: 60px;">
				<span class="headImg"><img alt="image" class="img-circle" src="${ownStatic}/images/default_headimg.jpg"></span>
				<a data-toggle="dropdown" class="dropdown-toggle" style="height: 100%;" href="javascript:void(0);" aria-expanded="false">
                                <span class="clear">
                               <span class="block m-t-xs"><strong class="font-bold">${fns:getUser().office.name}</strong></span>
                                <span class="text-muted text-xs block">${fns:getUser().name}<b class="caret"></b></span>
                                </span>
				</a>
				<ul class="dropdown-menu animated fadeInRight m-t-xs" >
					<li>
						<a class="J_menuItem" href="${ctx}/sys/user/info" target='mainFrame'>个人信息</a>
					</li>
					<li>
						<a class="J_menuItem" href="${ctx}/sys/user/modifyPwd" target='mainFrame'>修改密码</a>
					</li>
					<li class="divider"></li>
					<li>
						<a href="${ctx}/logout">安全退出</a>
					</li>
				</ul>
			</li>
		</ul>
	</nav>
	<!--顶部导航结束-->
	<!--顶部二级导航开始-->
	<div class="second-sub-nav" id="transverse-second-nav">
		<!--左侧二级导航开始-->
		<div class="navbar-default navbar-static-side left-nav"></div>
	</div>
	<!--顶部二级导航结束-->

	<!--左侧导航开始-->
	<!--左侧总导航开始-->
	<nav class="navbar-default total-navbar close-navbar ">
		<div class="sidebar-collapse">
			<div class="total-navbar-toggle">
				<i class="fa icon-reorder"></i>
			</div>
			<ul class="nav">
				<c:set var="firstMenu" value="true"/>
				<c:forEach items="${fns:getMenuList()}" var="menu" varStatus="idxStatus">
					<c:if test="${menu.parent.id eq '1'&&menu.isShow eq '1'}">
						<li class="menu ${not empty firstMenu && firstMenu ? ' active' : ''}">
							<c:if test="${empty menu.href}">
								<a href="javascript:void(0);" data-href="${ctx}/sys/menu/tree?parentId=${menu.id}" data-id="${menu.id}">
									<i class="${not empty menu.icon ? menu.icon : 'icon-th-large'}"></i>
									<span class="nav-label">${menu.name}</span>
								</a>
							</c:if>
							<c:if test="${not empty menu.href}">
								<a href="${fn:indexOf(menu.href, '://') eq -1 ? ctx : ''}${menu.href}" data-id="${menu.id}">
									<i class="${not empty menu.icon ? menu.icon : 'icon-th-large'}"></i>
									<span class="nav-label">${menu.name}</span>
								</a>
							</c:if>
						</li>
						<c:if test="${firstMenu}">
							<c:set var="firstMenuId" value="${menu.id}"/>
						</c:if>
						<c:set var="firstMenu" value="false"/>
					</c:if>
				</c:forEach>
			</ul>
		</div>
	</nav>
	<!--左侧总导航结束-->

	<!--左侧导航结束-->
	<!--右侧部分开始-->
	<div id="page-wrapper" class="gray-bg dashbard-1 true-height" style="height: calc( 100% - 60px)">
		<!--二级导航-->
		<div class="second-nav" id="second-nav">
			<!--左侧二级导航开始-->
			<div class="navbar-default navbar-static-side left-nav"></div>
		</div>
		<!--伸缩二级导航按钮-->
		<div class="display-arrow second-nav-open">
			<i class="fa icon-double-angle-left"></i>
			<i class="fa icon-double-angle-right" style="display: none;"></i>
		</div>
		<!--主体部分-->
		<div class="page-main">
			<div class="row content-tabs">
				<button class="roll-nav roll-left J_tabLeft"><i class="fa icon-backward"></i>
				</button>
				<nav class="page-tabs J_menuTabs">
					<div class="page-tabs-content">
					</div>
				</nav>
				<button class="roll-nav roll-right J_tabRight"><i class="fa icon-forward"></i>
				</button>
				<!--关闭操作-->
				<div class="btn-group roll-nav roll-right">
					<button class="dropdown J_tabClose" data-toggle="dropdown">关闭操作<span class="caret"></span>
					</button>
					<ul role="menu" class="dropdown-menu dropdown-menu-right">
						<li class="J_tabCloseAll">
							<a>关闭全部选项卡</a>
						</li>
						<li class="J_tabCloseOther">
							<a>关闭其他选项卡</a>
						</li>
					</ul>
				</div>
				<div class="roll-nav roll-right J_tabExit">
					<button class="dropdown J_tabClose" data-toggle="dropdown">主题</button>
					<ul role="menu" class="dropdown-menu dropdown-menu-right layout-dropdown">
						<li class="J_tabCloseAll nui-form">
							<c:forEach items="${fns:getDictList('theme')}" var="dict">
								<li class="J_tabCloseAll"><a href="#" onclick="location='${pageContext.request.contextPath}/theme/${dict.value}?url='+location.href">${dict.label}</a></li>
							</c:forEach>
						</li>
					</ul>
				</div>
			</div>
			<div class="row J_mainContent" id="content-main">
				<iframe class="J_iframe" name="iframe0" width="100%" height="100%" src="" frameborder="0" seamless></iframe>
			</div>
			<div class="footer">
				<div class="pull-right">
					Copyright &copy; 2012-${fns:getConfig('copyrightYear')} <a href="#">${fns:getConfig('productName')}</a> - Powered By <a href="${fns:getConfig('group.url')}" target="_blank">${fns:getConfig('group')}</a> ${fns:getConfig('version')}
				</div>
			</div>
		</div>
		<!---->
	</div>
	<!--右侧部分结束-->
</div>
<script>
	/*一级导航操作*/
	//左右布局导航
	function vertical_nav(){
		$('.left-right-layout .total-navbar .nav>li>a').click(function (event) {
			$(this).removeAttr('data-index');
			event.preventDefault();
			//一级导航加click事件
			$(this).parent('li').addClass('active').siblings('li').removeClass('active');
			// 显示二级菜单
			var menuId = "#menu-" + $(this).attr("data-id");
			 if ($(menuId).length > 0){
				$(".left-right-layout  #second-nav .left-nav .accordion").hide();
				$(menuId).show();
				// 初始化点击第一个二级菜单
				if ($(menuId + " .accordion-body:first").hasClass('in')){
					//$(menuId + " .accordion-heading:first a").click();
					$(menuId + " .accordion-heading:first a").parents('.accordion-group').addClass('accordion-group-active');
				}else{
					$(menuId + " .accordion-body:first").addClass('in');
					//$(menuId + " .accordion-heading:first a").click();
					$(menuId + " .accordion-heading:first a").parents('.accordion-group').addClass('accordion-group-active');
				}
				if (!$(menuId + " .accordion-body li:first ul:first").is(":visible")){
					$(menuId + " .accordion-body a:first i").click();
					$(this).parents('.accordion-group').addClass('accordion-group-active');
					$(menuId + " .accordion-heading:first a").parents('.accordion-group').addClass('accordion-group-active');
				}
				// 初始化点击第一个三级菜单
				$(menuId + " .accordion-body li:first li:first a:first i").click();
			}else{ 
				// 获取二级菜单数据
				$.get($(this).attr("data-href"), function(data){
					if (data.indexOf("id=\"loginForm\"") != -1){
						alert('未登录或登录超时。请重新登录，谢谢！');
						top.location = "${ctx}";
						return false;
					}
					$(".left-right-layout #second-nav .left-nav .accordion").hide();
					$(".left-right-layout #second-nav .left-nav").append(data);
					if ($(menuId).length > 0){
						$(".left-right-layout #second-nav .left-nav .accordion").hide();
						$(menuId).show();
						// 初始化点击第一个二级菜单
						if ($(menuId + " .accordion-body:first").hasClass('in')){
							//$(menuId + " .accordion-heading:first a").click();
							$(menuId + " .accordion-heading:first a").parents('.accordion-group').addClass('accordion-group-active');
						}else{
							$(menuId + " .accordion-body:first").addClass('in');
							//$(menuId + " .accordion-heading:first a").click();
							$(menuId + " .accordion-heading:first a").parents('.accordion-group').addClass('accordion-group-active');
						}
						if (!$(menuId + " .accordion-body li:first ul:first").is(":visible")){
							$(menuId + " .accordion-body a:first i").click();
							$(this).parents('.accordion-group').addClass('accordion-group-active');
							$(menuId + " .accordion-heading:first a").parents('.accordion-group').addClass('accordion-group-active');
						}
						// 初始化点击第一个三级菜单
						$(menuId + " .accordion-body li:first li:first a:first i").click();
					}

					// 链接去掉虚框
					$(menuId + " a").bind("focus",function() {
						if(this.blur) {this.blur()};
					});
					// 二级标题
					$(menuId + " .accordion-heading a").click(function(){
						var id = $(this).attr('data-href');
						if($(id).hasClass('in')){
							$(id).removeClass('in');
							$(this).children('i').addClass('icon-angle-right').removeClass('icon-angle-down');					
							$(this).parents('.accordion-group').removeClass('accordion-group-active');
						}else{
							$(id).addClass('in');
							$(this).children('i').removeClass('icon-angle-right').addClass('icon-angle-down');
							$(this).parents('.accordion-group').addClass('accordion-group-active');
						}
					});
					// 二级内容
					$(menuId + " .accordion-body a").click(function(){
						$(menuId + " li").removeClass("active");
						$(menuId + " li i").removeClass("icon-white");
						$(this).parent().addClass("active");
						$(this).children("i").addClass("icon-white");
					});
					// 展现三级
					$(menuId + " .accordion-inner a").click(function(){
						var href = $(this).attr("data-href");
						if($(href).length > 0){
							$(href).toggle().parent().toggle();
							return false;
						}
						// <c:if test="${tabmode eq '1'}"> 打开显示页签
						return addTab($(this)); // </c:if>
					});
					// 默认选中第一个菜单
					$(menuId + " .accordion-body a:first i").click();
					$(menuId + " .accordion-body li:first li:first a:first i").click();
					//让第一个菜单的图标是向下的
					$(menuId + " .accordion-heading:first").find('i').removeClass('icon-angle-right').addClass('icon-angle-down');
				});
			 } 

		});
		// 初始化点击第一个一级菜单
		$('.left-right-layout .total-navbar .nav>li:first-child>a').click();
	};

	/*一级导航tooltip提示*/
	function addTooltip(tag){
		var li_text = tag.find('.nav-label').text();
		var tooltip_html = "<div class='nav-tooltip nav-tooltip-left'>"+li_text+"</div>"
		if($('.total-navbar').hasClass('close-navbar')){
			tag.append(tooltip_html);
		};
	};
	function removeTooltip(){
		$('.nav-tooltip').remove();
	};
	$('.total-navbar .nav>li').mouseover(function () {
		addTooltip($(this));
	}).mouseout(function (){
		removeTooltip()
	});

	/*兼容移动端触摸事件*/;
	//判断是不是移动端设备,如果是移动设备就将一级菜单的触摸事件变为点击事件，并在2s后，去除Tooltip
	if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
		$('.total-navbar .nav>li').click(function () {
			addTooltip($(this));
			setTimeout(removeTooltip,2000);
		})
	};
	/*一级导航收缩*/
	$('.total-navbar-toggle').click(function(){
		if($('.total-navbar').hasClass('close-navbar')){
			$('.total-navbar').addClass('open-navbar').removeClass('close-navbar')
			$('.total-navbar').css({'width':'140px'});
			$('#page-wrapper').css({'margin-left' : '140px'})
		}else {
			$('.total-navbar').addClass('close-navbar').removeClass('open-navbar')
			$('.total-navbar').css({'width':'50px'});
			$('#page-wrapper').css({'margin-left':'50px'})
		}
	});
	/*二级导航收缩*/
	var total_navbar = $('.total-navbar');
	var second_nav = $('#second-nav');
	var left_second_nav = $('.second-nav .navbar-static-side');
	var display_arrow = $('.display-arrow');
	var accordion_box = $('.second-nav .navbar-static-side .accordion');
	display_arrow.click(function () {
		if($(this).hasClass('second-nav-open')){
			second_nav.css('left','-160px');
			left_second_nav.css('left','-160px');
			accordion_box.css('left','-160px');
			total_navbar.css({'box-shadow':'none' , '-moz-box-shadow':'none' ,  '-webkit-box-shadow':'none' })
			$(this).css('left','0');
			$(this).removeClass('second-nav-open').addClass('second-nav-close');
			$('.display-arrow>i').eq(0).hide();
			$('.display-arrow>i').eq(1).show();
			$('.page-main').animate({'padding-left':'0'},200);
			
		}else {
			second_nav.css('left','0');
			left_second_nav.css('left','0');
			accordion_box.css('left','0');
			total_navbar.css({'box-shadow':'2px 0 3px rgba(21,39,35,0.6)' , '-moz-box-shadow':'2px 0 3px rgba(21,39,35,0.6)' ,  '-webkit-box-shadow':'2px 0 3px rgba(21,39,35,0.6)' })
			$(this).css('left','144px');
			$(this).removeClass('second-nav-close').addClass('second-nav-open');
			$('.display-arrow>i').eq(1).hide();
			$('.display-arrow>i').eq(0).show();
			$('.page-main').animate({'padding-left':'160px'},200);
		}
	});
	// 获取通知数目  <c:set var="oaNotifyRemindInterval" value="${fns:getConfig('oa.notify.remind.interval')}"/>
	function getNotifyNum(){
		$.get("${ctx}/oa/oaNotify/self/count?updateSession=0&t="+new Date().getTime(),function(data){
			var num = parseFloat(data);
			if (num > 0){
				$("#notifyNum , #notifyNum2").show().html("("+num+")");
			}else{
				$("#notifyNum , #notifyNum2").hide()
			}
		});
	}
	getNotifyNum(); //<c:if test="${oaNotifyRemindInterval ne '' && oaNotifyRemindInterval ne '0'}">
	setInterval(getNotifyNum, ${oaNotifyRemindInterval}); //</c:if> 
	vertical_nav(); 
</script>
</body>
</html>